package com.yonyou.cloud.member.adapters.repository.orm;

import com.yonyou.cloud.member.adapters.repository.orm.dao.MemberDao;
import com.yonyou.cloud.member.domainmodel.entities.member.Member;
import com.yonyou.cloud.member.domainmodel.vo.MemberId;
import com.yonyou.cloud.member.domainmodel.repositories.MemberRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MemberRepositoryImpl implements MemberRepository {
    @Autowired
    MemberDao memberDao;

    @Override
    public Member find(MemberId id) {
        return memberDao.findById(id);
    }

    @Override
    public Member find(String phone) {
        return memberDao.findByPhone(phone);
    }

    @Override
    public List<Member> list(String level) {
        return memberDao.listByLevel(level);
    }

    @Override
    public int count() {
        return memberDao.count();
    }

    // @Transactional
    @Override
    public boolean insert(Member member) {
        return memberDao.insert(member);
    }

    // @Transactional
    @Override
    public boolean delete(MemberId id) {
        return memberDao.delete(id);
    }
}
